package com.neusoft.databus.common.connection;

import com.neusoft.bizcore.web.utils.JsonUtils;

import lombok.Getter;
import lombok.Setter;

/**
 * OPC连接配置
 *
 * @author naxiang
 */
@Getter
@Setter
public class OpcConnection extends AbstractConnection {

    private static final long serialVersionUID = 1L;
    // 主机名
    private String host;
    // 域名
    private String domain;
    // 用户名
    private String user;
    // 密码
    private String password;
    // 进程标识
    private String progid;
    // 类的唯一标识
    private String clsid;

    @Override
    public int hashCode() {
        //final String key = this.clsid + this.domain + this.host + this.user + this.password + this.progid;
        final String key = this.host;
        return key.hashCode();
    }

    @Override
    public boolean equals(Object o) {
        if (o instanceof OpcConnection) {
            return this.hashCode() == ((OpcConnection) o).hashCode();
        }
        return false;
    }

    @Override
    public OpcConnection asUsedConnection() {
        return this;
    }

    @Override
    public String toString() {
        return JsonUtils.pojoToJson(this);
    }

}
